/*    */ package com.cr.framework.shiro.web.filter;
/*    */ 
/*    */ import com.cr.common.core.domain.entity.SysUser;
/*    */ import com.cr.common.utils.MessageUtils;
/*    */ import com.cr.common.utils.ShiroUtils;
/*    */ import com.cr.common.utils.MyStringUtils;
/*    */ import com.cr.common.utils.spring.SpringUtils;
/*    */ import com.cr.framework.manager.AsyncManager;
/*    */ import com.cr.framework.manager.factory.AsyncFactory;
/*    */ import com.cr.system.service.ISysUserOnlineService;
/*    */ import javax.servlet.ServletRequest;
/*    */ import javax.servlet.ServletResponse;
/*    */ import org.apache.shiro.session.SessionException;
/*    */ import org.apache.shiro.subject.Subject;
/*    */
/*    */ import org.apache.shiro.web.filter.authc.LogoutFilter;
import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class MyLogoutFilter extends LogoutFilter {
/* 26 */   private static final Logger log = LoggerFactory.getLogger(MyLogoutFilter.class);
/*    */   
/*    */   private String loginUrl;
/*    */   
/*    */   public String getLoginUrl() {
/* 35 */     return this.loginUrl;
/*    */   }
/*    */   
/*    */   public void setLoginUrl(String loginUrl) {
/* 40 */     this.loginUrl = loginUrl;
/*    */   }
/*    */   
/*    */   protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
/*    */     try {
/* 48 */       Subject subject = getSubject(request, response);
/* 49 */       String redirectUrl = getRedirectUrl(request, response, subject);
/*    */       try {
/* 52 */         SysUser user = ShiroUtils.getSysUser();
/* 53 */         if (MyStringUtils.isNotNull(user)) {
/* 55 */           String loginName = user.getLoginName();
/* 57 */           AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, "Logout", MessageUtils.message("user.logout.success", new Object[0]), new Object[0]));
/* 59 */           ((ISysUserOnlineService)SpringUtils.getBean(ISysUserOnlineService.class)).removeUserCache(loginName, ShiroUtils.getSessionId());
/*    */         } 
/* 62 */         subject.logout();
/* 64 */       } catch (SessionException ise) {
/* 66 */         log.error("logout fail.", (Throwable)ise);
/*    */       } 
/* 68 */       issueRedirect(request, response, redirectUrl);
/* 70 */     } catch (Exception e) {
/* 72 */       log.error("Encountered session exception during logout.  This can generally safely be ignored.", e);
/*    */     } 
/* 74 */     return false;
/*    */   }
/*    */   
/*    */   protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject) {
/* 83 */     String url = getLoginUrl();
/* 84 */     if (MyStringUtils.isNotEmpty(url))
/* 86 */       return url; 
/* 88 */     return super.getRedirectUrl(request, response, subject);
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-framework-4.7.0.jar!\com\cr\framework\shiro\web\filter\LogoutFilter.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */